package com.hotel.system.service.impl;

import com.hotel.common.constant.Constants;
import com.hotel.common.utils.ShiroUtils;
import com.hotel.common.utils.StringUtils;
import com.hotel.system.domain.hotel.Room;
import com.hotel.system.domain.hotel.RoomType;
import com.hotel.system.mapper.RoomMapper;
import com.hotel.system.mapper.SysUserPostMapper;
import com.hotel.system.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 岗位信息 服务层处理
 * 
 * @author hotel
 */
@Service
public class RoomServiceImpl implements RoomService
{


    @Autowired
    private RoomMapper roomMapper;


    @Override
    public List<Room> selectRoomList(Room room) {
        return roomMapper.selectRoomList(room);
    }
    @Override
    public int insertRoom(Room room)
    {
        room.setDeptId(ShiroUtils.getSysUser().getDeptId());
        room.setCreateBy(ShiroUtils.getLoginName());
        room.setUpdateBy(ShiroUtils.getLoginName());

        return roomMapper.insertRoom(room);
    }


    @Override
    public Room selectRoomId(String id)
    {

        return roomMapper.selectRoomId(id);
    }



    @Override
    public int updateRoom(Room room)
    {
        return roomMapper.updateRoom(room);
    }

    @Override
    public int updateRoomStatus(String ids) {

        return roomMapper.updateRoomStatus(ids);
    }

    @Override
    public boolean checkRoomNameUnique(Room room) {
        Long roomId = StringUtils.isNull(room.getId()) ? -1L : room.getId();
        Room info = roomMapper.checkRoomNameUnique(room.getRoomName(), room.getDeptId());
        if (StringUtils.isNotNull(info) && info.getId().longValue() != roomId.longValue())
        {
            return Constants.NOT_UNIQUE;
        }
        return Constants.UNIQUE;
    }


}
